package com.pennphoto.client;

import java.util.ArrayList;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * This interface is used to make calls from the browser in JavaScript,
 * to the server's Java code in QueryTablesAsync
 * 
 * @author zives
 *
 */
@RemoteServiceRelativePath("QueryXML")
public interface QueryXML extends RemoteService {
	/**
	 * Utility class for simplifying access to the instance of async service.
	 */
	public static class Util {
		private static QueryXMLAsync instance;
		public static QueryXMLAsync getInstance(){
			if (instance == null) {
				instance = GWT.create(QueryXML.class);
			}
			return instance;
		}
	}
	
	/**
	 * Returns the ID of the first person in the data
	 * 
	 * @param xml
	 * @return
	 * @throws IllegalArgumentException
	 * @throws Exception 
	 */
	public Integer getFirstPerson(final String xml) throws IllegalArgumentException, Exception;
	
	/**
	 * Retrieves the person plus his or her circles, with the circles expanded
	 * to include person ID and name
	 * 
	 * @param xml
	 * @param person
	 * @return
	 * @throws IllegalArgumentException
	 * @throws Exception 
	 */
	public String getPersonAndNeighbors(final int person) throws IllegalArgumentException, Exception;

	/**
	 * Get a specific person's photos list in XML
	 *
	 * @param xml Original XML file
	 * @param person ID of person
	 * @param first Index of first photo
	 * @param count How many photos
	 * @return
	 * @throws IllegalArgumentException
	 * @throws Exception 
	 */
	public String getPhotos( int person, int first, int count)
			throws IllegalArgumentException, Exception;
	public ArrayList<Integer> getFriends(final int person) throws IllegalArgumentException, Exception;
}
